package o;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.huawei.appmarket.service.apppermission.bean.GroupPermissionInfo;
import com.huawei.appmarket.service.apppermission.bean.PermissionInfo;
import com.huawei.appmarket.service.apppermission.bean.SingleAppPermissionInfo;
import java.util.ArrayList;
import o.ewm.h;
import o.ewm.j;

public class dtq implements ExpandableListAdapter {
    private Context ˊ;
    private ArrayList<SingleAppPermissionInfo> ˎ;
    private int ॱ;

    static class d {
        private TextView ˊ;
        private LinearLayout ˎ;
        private ImageView ˏ;
        private TextView ॱ;

        private d() {
        }
    }

    static class e {
        private ImageView ˋ;
        private ImageView ˏ;
        private TextView ॱ;

        private e() {
        }
    }

    public dtq(Context context, @NonNull ArrayList<SingleAppPermissionInfo> arrayList) {
        this.ˊ = context;
        this.ˎ = arrayList;
        this.ॱ = context.getResources().getDimensionPixelSize(o.ewm.d.ꜟ);
    }

    public void registerDataSetObserver(DataSetObserver dataSetObserver) {
    }

    public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
    }

    public int getGroupCount() {
        return this.ˎ.size();
    }

    public Object getGroup(int i) {
        return ((SingleAppPermissionInfo) this.ˎ.get(i)).ˋ();
    }

    public long getGroupId(int i) {
        return (long) i;
    }

    public View getGroupView(int i, boolean z, View view, ViewGroup viewGroup) {
        String str = (String) getGroup(i);
        if (view == null || !(view.getTag() instanceof e)) {
            view = LayoutInflater.from(this.ˊ).inflate(h.ˋॱ, null);
            e eVar = new e();
            eVar.ॱ = (TextView) view.findViewById(j.ॱʿ);
            eVar.ॱ.setText(str);
            eVar.ˏ = (ImageView) view.findViewById(j.ߵ);
            eVar.ˏ.setVisibility(0);
            eVar.ˋ = (ImageView) view.findViewById(j.ˑॱ);
            view.setTag(eVar);
        }
        e eVar2 = (e) view.getTag();
        eVar2.ॱ.setText(str);
        if (z) {
            eVar2.ˏ.setVisibility(8);
            eVar2.ˋ.setImageResource(o.ewm.e.ॱʻ);
        } else {
            eVar2.ˏ.setVisibility(0);
            eVar2.ˋ.setImageResource(o.ewm.e.ˏˏ);
        }
        if (getGroupCount() == i + 1) {
            eVar2.ˏ.setVisibility(8);
        }
        return view;
    }

    private int ˋ(int i, int i2) {
        int i3 = -1;
        for (GroupPermissionInfo groupPermissionInfo : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i3++;
            if (i2 == i3) {
                return 0;
            }
            int size = groupPermissionInfo.ˏ().size() + i3;
            if (i2 <= size) {
                return 1;
            }
            i3 = size;
        }
        return 1;
    }

    public int getChildrenCount(int i) {
        int i2 = 0;
        for (GroupPermissionInfo ˏ : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i2 = ˏ.ˏ().size() + (i2 + 1);
        }
        return i2;
    }

    public Object getChild(int i, int i2) {
        int i3 = -1;
        for (GroupPermissionInfo groupPermissionInfo : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i3++;
            if (i2 == i3) {
                return groupPermissionInfo.ˎ();
            }
            int size = groupPermissionInfo.ˏ().size();
            i3 += size;
            if (i2 <= i3) {
                return ((PermissionInfo) groupPermissionInfo.ˏ().get((size - (i3 - i2)) - 1)).ॱ();
            }
        }
        return "";
    }

    public long getChildId(int i, int i2) {
        return (long) i2;
    }

    private boolean ॱ(int i, int i2) {
        int i3 = -1;
        for (GroupPermissionInfo groupPermissionInfo : ((SingleAppPermissionInfo) this.ˎ.get(i)).ॱ()) {
            i3++;
            if (i3 == i2 && i3 != 0) {
                return true;
            }
            if (i3 >= i2) {
                return false;
            }
            i3 = groupPermissionInfo.ˏ().size() + i3;
        }
        return false;
    }

    private boolean ˎ(int i, int i2) {
        if (i2 == getChildrenCount(i) - 1) {
            return true;
        }
        return false;
    }

    public View getChildView(int i, int i2, boolean z, View view, ViewGroup viewGroup) {
        View ॱ = ॱ(view);
        String str = (String) getChild(i, i2);
        d dVar = (d) ॱ.getTag();
        if (ˋ(i, i2) == 0) {
            ˊ(i, i2, str, dVar);
        } else {
            ˋ(i, i2, str, dVar);
        }
        return ॱ;
    }

    private void ˋ(int i, int i2, String str, d dVar) {
        dVar.ॱ.setText(str);
        dVar.ˎ.setVisibility(0);
        dVar.ˊ.setVisibility(8);
        if (ˎ(i, i2)) {
            dVar.ˏ.setVisibility(0);
        } else {
            dVar.ˏ.setVisibility(8);
        }
    }

    private void ˊ(int i, int i2, String str, d dVar) {
        dVar.ˊ.setText(str);
        dVar.ˏ.setVisibility(8);
        dVar.ˎ.setVisibility(8);
        dVar.ˊ.setVisibility(0);
        if (ॱ(i, i2)) {
            dVar.ˊ.setPadding(0, this.ॱ, 0, 0);
        } else {
            dVar.ˊ.setPadding(0, 0, 0, 0);
        }
    }

    private View ॱ(View view) {
        if (view != null && (view.getTag() instanceof d)) {
            return view;
        }
        view = LayoutInflater.from(this.ˊ).inflate(h.ॱॱ, null);
        d dVar = new d();
        dVar.ˊ = (TextView) view.findViewById(j.ॱʾ);
        dVar.ॱ = (TextView) view.findViewById(j.ॱʿ);
        dVar.ˏ = (ImageView) view.findViewById(j.ߵ);
        dVar.ˎ = (LinearLayout) view.findViewById(j.ॱˉ);
        view.setTag(dVar);
        return view;
    }

    public boolean hasStableIds() {
        return false;
    }

    public boolean isChildSelectable(int i, int i2) {
        return false;
    }

    public boolean areAllItemsEnabled() {
        return false;
    }

    public boolean isEmpty() {
        return false;
    }

    public void onGroupExpanded(int i) {
    }

    public void onGroupCollapsed(int i) {
    }

    public long getCombinedChildId(long j, long j2) {
        return 0;
    }

    public long getCombinedGroupId(long j) {
        return 0;
    }
}
